if SERVER then
	registerCommand("savecoords", "Saves a set of coordinates for use with loadcoords or sendtocoords - Takes a save name optionally followed by x, y, z coordinates (otherwise it takes your location automatically)", function(param)
		if not param[1]:IsValid() then
			return nil
		end
		
		local savecoordsMsg = "caller saved coordinates coords as name"
		if param["settings"]["savecoords_msg"] then
			savecoordsMsg = param["settings"]["savecoords_msg"]
		end
		local savecoordsTable = {}
		savecoordsTable["caller"] = getCaller(param[1])
		local targ = string.Explode(" ", param[3])
		if table.Count(targ) >= 4 then
			local saveLoc = targ[1]
			savecoordsTable["name"] = saveLoc
			savecoordsTable["coords"] = targ[2] .. ", " .. targ[3] .. ", " .. targ[4]
			param[1]["moocow_coord" .. saveLoc .. "x"] = tonumber(targ[2])
			param[1]["moocow_coord" .. saveLoc .. "y"] = tonumber(targ[3])
			param[1]["moocow_coord" .. saveLoc .. "z"] = tonumber(targ[4])
			display(param[1], "savecoords", { nil }, parseDisplayMessage(savecoordsMsg, savecoordsTable))
		elseif table.Count(targ) == 1 then
			local saveLoc = targ[1]
			local savePos = param[1]:GetPos()
			savecoordsTable["name"] = saveLoc
			savecoordsTable["coords"] = tostring(savePos.x) .. ", " .. tostring(savePos.y) .. ", " .. tostring(savePos.z)
			param[1]["moocow_coord" .. saveLoc .. "x"] = savePos.x
			param[1]["moocow_coord" .. saveLoc .. "y"] = savePos.y
			param[1]["moocow_coord" .. saveLoc .. "z"] = savePos.z
			display(param[1], "savecoords", { nil }, parseDisplayMessage(savecoordsMsg, savecoordsTable))
		end
	end)
	
	registerCommand("loadcoords", "Sends yourself to the save name of the coordinates you specify", function(param)
		if not param[1]:IsValid() then
			return nil
		end
		
		local loadcoordsMsg = "caller teleported to coordinates coords, name"
		local loadcoordsSound = "ambient/machines/teleport3.wav" //teleport1.wav also sounds nice
		if param["settings"]["loadcoords_msg"] then
			loadcoordsMsg = param["settings"]["loadcoords_msg"]
		end
		if param["settings"]["loadcoords_sound"] then
			loadcoordsSound = param["settings"]["loadcoords_sound"]
		end
		local loadcoordsTable = {}
		loadcoordsTable["caller"] = getCaller(param[1])
		local targ = string.Explode(" ", param[3])
		if table.Count(targ) == 1 then
			local loadLoc = targ[1]
			loadcoordsTable["name"] = loadLoc
			if param[1]["moocow_coord" .. loadLoc .. "x"] then
				local loadPos = Vector(param[1]["moocow_coord" .. loadLoc .. "x"], param[1]["moocow_coord" .. loadLoc .. "y"], param[1]["moocow_coord" .. loadLoc .. "z"])
				loadcoordsTable["coords"] = tostring(loadPos.x) .. ", " .. tostring(loadPos.y) .. ", " .. tostring(loadPos.z)
				
				local prop = ents.Create("prop_physics")
				prop:SetModel("props_wasteland/controlroom_filecabinet002a")
				prop:SetPos(loadPos)
				prop:PhysicsInit()
				prop:PhysWake()
				if prop:IsInWorld() then
					param[1]:SetPos(loadPos)
					param[1]:EmitSound(loadcoordsSound)
					display(param[1], "loadcoords", { nil }, parseDisplayMessage(loadcoordsMsg, loadcoordsTable))
				end
				prop:Remove()
			end
		end
	end)
	
	registerCommand("sendtocoords", "Sends the player you specify to the coordinate save name you specify", function(param)
		if not param[1]:IsValid() then
			return nil
		end
		
		local sendtocoordsMsg = "caller teleported target to coordinates coords, name"
		local sendtocoordsSound = "ambient/machines/teleport3.wav" //teleport1.wav also sounds nice
		if param["settings"]["sendtocoords_msg"] then
			sendtocoordsMsg = param["settings"]["sendtocoords_msg"]
		end
		if param["settings"]["sendtocoords_sound"] then
			sendtoSound = param["settings"]["sendtocoords_sound"]
		end
		local sendtocoordsTable = {}
		sendtocoordsTable["caller"] = getCaller(param[1])
		local targ = string.Explode(" ", param[3])
		if table.Count(targ) == 2 then
			local plyTarg = getPlayerByName(targ[1])
			if plyTarg then
				sendtocoordsTable["target"] = plyTarg:GetName()
				local sendtoLoc = targ[2]
				sendtocoordsTable["name"] = sendtoLoc
				if param[1]["moocow_coord" .. sendtoLoc .. "x"] then
					local sendtoPos = Vector(param[1]["moocow_coord" .. sendtoLoc .. "x"], param[1]["moocow_coord" .. sendtoLoc .. "y"], param[1]["moocow_coord" .. sendtoLoc .. "z"])
					sendtocoordsTable["coords"] = tostring(sendtoPos.x) .. ", " .. tostring(sendtoPos.y) .. ", " .. tostring(sendtoPos.z)
					
					local prop = ents.Create("prop_physics")
					prop:SetModel("props_wasteland/controlroom_filecabinet002a")
					prop:SetPos(sendtoPos)
					prop:PhysicsInit()
					prop:PhysWake()
					if prop:IsInWorld() then
						plyTarg:SetPos(sendtoPos)
						plyTarg:EmitSound(sendtocoordsSound)
						display(param[1], "sendtocoords", { plyTarg }, parseDisplayMessage(sendtocoordsMsg, sendtocoordsTable))
					end
					prop:Remove()
				end
			end
		end
	end)
end